package com.ibm.law.ui.common;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.commons.beanutils.PropertyUtils;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.ibm.law.domain.Model;

class TableLabelProvider extends LabelProvider implements ITableLabelProvider {

	private Model model;

	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	public String getColumnText(Object element, int columnIndex) {
		List<String> columnList=model.getColumnList();
		try {
			Object object= PropertyUtils.getProperty(element, columnList.get(columnIndex));
			return object+"";
		} catch (IllegalAccessException | InvocationTargetException
				| NoSuchMethodException e) {
			e.printStackTrace();
		}
		return "";
	}

	public TableLabelProvider(Model model) {
		super();
		this.model = model;
	}
}